﻿
namespace Magalie.Web
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Web.Ria;
    using System.Web.Ria.Data;
    using System.Web.DomainServices;
    using System.Data;
    using System.Web.DomainServices.LinqToEntities;


    // Implements application logic using the AdventureWorksEntities context.
    // TODO: Add your application logic to these methods or in additional methods.
    [EnableClientAccess()]
    public class TestDomainService : LinqToEntitiesDomainService<AdventureWorksEntities>
    {

        // TODO: Consider
        // 1. Adding parameters to this method and constraining returned results, and/or
        // 2. Adding query methods taking different parameters.
        public IQueryable<Employee> GetEmployee()
        {
            return this.Context.Employee;
        }

        public void InsertEmployee(Employee employee)
        {
            this.Context.AddToEmployee(employee);
        }

        public void UpdateEmployee(Employee currentEmployee)
        {
            this.Context.AttachAsModified(currentEmployee, this.ChangeSet.GetOriginal(currentEmployee));
        }

        public void DeleteEmployee(Employee employee)
        {
            if ((employee.EntityState == EntityState.Detached))
            {
                this.Context.Attach(employee);
            }
            this.Context.DeleteObject(employee);
        }
    }
}


